package leetCode.firstWeek;

public class Code_11 {
    public int maxArea(int[] height) {
        int max = 0;
        for (int i = 0; i < height.length; i++) {
            for (int j = i; j < height.length; j++) {
                if (whatWater(i, j, height) > max) {
                    max = whatWater(i, j, height);
                }
            }
        }
        return max;
    }

    public static int whatWater(int index1, int index2, int[] arr) {
        int width = index1 - index2 > 0 ? index1 - index2 : index2 - index1;
        int height = arr[index1] - arr[index2] > 0 ? arr[index2] : arr[index1];
        return width * height;
    }
}
